<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/login.css"/>
		<link href="bitbug_favicon.ico" rel="shortcut icon" />
	</head>
	<body>
		<div class="log">
			<h2>注册</h2>
			<p class="username">用户名：<input id="username" type="text" placeholder="请输入用户名"/></p>
			<p class="pws">密&nbsp;码：&nbsp;&nbsp;<input id="password" type="password" placeholder="请输入密码"/></p>
			<p class="pws">邮&nbsp;箱：&nbsp;&nbsp;<input id="email" type="email" placeholder="请输入邮箱"/></p>
			<p class="pws">昵&nbsp;称：&nbsp;&nbsp;<input id="name" type="text" placeholder="请输入昵称"/></p>
			<p class="button">
				<a href="index.html">取消</a>
				<a href="javascript:;" id="ok">注册</a>
			</p>
		</div>
	</body>
	<script src="js/jquery1111.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/config.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$('#ok').click(function(){
			if($('#username').val() == null || $('#username').val().trim() == ''){
				alert("用户名不能为空");
				return;
			}
			if($('#password').val() == null || $('#password').val().trim() == ''){
				alert("密码不能为空");
				return;
			}
			if($('#email').val() == null || $('#email').val().trim() == ''){
				alert("邮箱不能为空");
				return;
			}
			if($('#name').val() == null || $('#name').val().trim() == ''){
				alert("昵称不能为空");
				return;
			}
			$.ajax({
				url: serverPath + 'addUser',
				data:{
					'user.username':$('#username').val(),
					'user.password':$('#password').val(),
					'user.mail':$('#email').val(),
					'user.name':$('#name').val(),
				},
				type: 'get',
				dataType: 'json',
				success: function(json){
					if(json.code==2001){
						alert(json.msg)
					}else{
						alert('恭喜您注册成功')
						window.location = 'login.html';
					}
					
				},
				error: function(){
					alert('error');
				}
			});
			
		})
	</script>
</html>
